package com.xmx.mapper;

import com.xmx.entity.Roles;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IRolesMapper {
    //查询角色
    @Select("select r.* from roles r,user_roles ur where r.rid = ur.rid and ur.uid = #{id}")
    List<Roles> queryRolesByuserid(Integer id);

    //查询所有角色信息
    @Select("select * from roles")
    List<Roles> queryAllRoles();
//    //根据角色id查询角色
//    @Select("select * from roles where rid=#{id}")
//    Roles queryRolesById(Integer id);
    //添加角色信息
    @Insert("insert into roles values(null,#{rname},#{rdesc})")
    void addNewRoles(Roles roles);

    //根据角色名查询id
    @Select("select * from roles where rname=#{rname}")
    Roles queryRoleByname(String name);

    //根据rid删除角色
    @Delete("delete from roles where rid=#{rid}")
    void deleterole(Integer rid);
}
